<template>
  <el-menu
    class="el-menu-demo"
    mode="horizontal"
    :ellipsis="false"
    :background-color="color"
    text-color="#409eff"
  >
    <el-menu-item index="0" @click="menuIn"
      ><el-icon color="#409EFC" :size="20"> <Grid /> </el-icon>
      {{ store.state.isCollapse ? "展开" : "收起" }}
    </el-menu-item>
    <div class="flex-grow" />
    <el-sub-menu index="2">
      <template #title>
        <img
          class="el-dropdown-link"
          src="../assets/011d125bada9dda801213deae4ed54.jpg@1280w_1l_2o_100sh.jpg"
          alt="logo"
        />
        <h4>admin</h4>
      </template>
      <el-menu-item index="2-1">退出登录</el-menu-item>
      <el-menu-item index="2-2">修改密码</el-menu-item>
      <el-sub-menu index="2-4">
        <template #title>切换背景颜色</template>
        <el-menu-item index="2-4-1" @click="changeY">黄色</el-menu-item>
        <el-menu-item index="2-4-2">蓝色</el-menu-item>
      </el-sub-menu>
    </el-sub-menu>
  </el-menu>
</template>

<script lang="ts" setup>
import { Grid } from "@element-plus/icons-vue";
import { computed, ref } from "vue";
import { useStore } from "vuex";
let color = ref("#51565c");
const changeY = () => {
  color = ref("#244211");
};
const store = useStore();
//vuex commit方法
const menuIn = () => {
  store.commit("menuOut");
};
</script>

<style lang="less" scoped>
.header-container {
  height: 60px;
  background-color: #333;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0px 20px;
  span {
    color: white;
    font-size: 14px;
    margin-left: 10px;
  }
}
.el-dropdown-link {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 10px;
}
.el-icon-arrow-down {
  font-size: 12px;
}
.flex-grow {
  flex-grow: 1;
}
.el-menu {
  height: 100%;
  // padding: 0 20px;
}
</style>
